home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / bm_cpio.gz / unixbm.cpio / header.c < prev    next >
C/C++ Source or Header  |  1994-07-11  |  951b  |  58 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include "bm.h"
  4. #include "header.h"
  5.  
  6. struct token hd[] = {
  7.     "Status: ", STATUS,
  8.     "Status: ", STATUS,
  9.     "Received: ", RECEIVED,
  10.     "From: ", FROM,
  11.     "To: ", TO,
  12.     "Date: ", DATE,
  13.     "Message-Id: ", MSGID,
  14.     "Subject: ", SUBJECT,
  15.     "Reply-To: ", REPLYTO,
  16.     "Sender: ", SENDER,
  17.     NULLCHAR, 0
  18. };
  19.  
  20. /* return the header token type */
  21. int
  22. htype(s)
  23. char *s;
  24. {
  25.     register char *p;
  26.     register struct token *hp;
  27.  
  28.     p = s;
  29.     /* check to see if there is a ':' before and white space */
  30.     while (*p != '\0' && *p != ' ' && *p != ':')
  31.         p++;
  32.     if (*p != ':')
  33.         return NOHEADER;
  34.  
  35.     for (p = s, hp = hd; hp->str != NULLCHAR; hp++) {
  36.         if (prefix(hp->str,p))
  37.             return hp->type;
  38.     }
  39.     return UNKNOWN;
  40. }
  41.  
  42. prefix(pref,full)
  43. register char *pref, *full;
  44. {
  45.     register char fc, pc;
  46.  
  47.     while ((pc = *pref++) != '\0') {
  48.         fc = *full++;
  49.         if (isupper(fc))
  50.             fc = tolower(fc);
  51.         if (isupper(pc))
  52.             pc = tolower(pc);
  53.         if (fc != pc)
  54.             return 0;
  55.     }
  56.     return 1;
  57. }
  58.